Skip to main content

Multi Query Support

With custom charts, we support multi-query functionality. Users can request any data query based on a contract in the lifecycle of the chart at any point and will receive a response. The user can customize the query by specifying which columnId data they want, as well as the offset and size of the data they wish to fetch.

You can perform a multi-query by using the ChartToTsEvent.getChartData event and passing an array of queries that you want to fetch.

Here is an example of how you can perform a multi-query:

const dataArr = ctx.emitEvent(ChartToTsEvent.getChartData, {
  queries: [
    {
      columnId: "<get from ctx.getColumns()>",
      offset: 0,
      size: 10,
    },
  ],
});

Sample data array:

dataArr = {
  columnId: "<get from ctx.getColumns()>",
  data: [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]
}

The return value will be of type DataPointArray, which will contain columnId and data, a two-dimensional array with each row representing the data for each columnId.